package com.prj.ufdm.auth.security;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Service;

/**
 * TOKEN 验证成功后处理
 * @author 胡义振  
 * @date 2018年3月22日
 */
@Service
public class TokenAuthenticationSuccess extends SimpleUrlAuthenticationSuccessHandler{
	
	@Override
	public void onAuthenticationSuccess(HttpServletRequest request,HttpServletResponse response, Authentication authentication)	throws IOException, ServletException {
		String context = request.getContextPath();
		String fullURL = request.getRequestURI();
		String url = fullURL.substring(fullURL.indexOf(context)	+ context.length());
		request.getRequestDispatcher(url).forward(request, response);
	}
}
